<template>
    <!-- 客户管理-NotePad页面 -->
    <div class="fillcontain">
        <el-form :model="searchParams" ref="ruleForm" label-width="100px" class="search_container" v-if="!isHebao">
            <el-row>
                <el-col :span="6">
                    <el-form-item label="客户号" prop="customerNo">
                        <el-input @keyup.enter.native="handleSubmit" clearable v-model.trim="searchParams.customerNo"
                                  placeholder="客户号"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="6" class="text_center">
                    <el-button type="primary" icon="el-icon-search" @click="subGetList"></el-button>
                    <el-button type="primary" plain icon="el-icon-refresh" @click="resetSearch"></el-button>
                </el-col>
            </el-row>
        </el-form>
        <div class="contain">
            <!-- 操作按钮 -->
            <el-row class="bgfff pb15" v-if="!allInfoReadOnly">
                <el-col :span="24" class="pt5">
                    <el-button type="danger" plain @click="addNotepade">新增</el-button>
                    <el-button type="danger" plain @click="showHistory">查看历史NOTEPAD</el-button>
                </el-col>
            </el-row>
            <div class="table_container">
                <el-table v-loading="loading" :data="tableData" @row-dblclick="detailNote(scope.row)"
                          highlight-current-row header-cell-class-name="table-header-class"
                          style="width:100%">
                    <el-table-column width="120" property="clttype" :formatter="ifnotepfx" label="客户类型" align='center'>
                    </el-table-column>
                    <el-table-column width="120" property="clntnum" label="客户号" align='center'>
                    </el-table-column>
                    <el-table-column width="120" property="clntname" label="客户名称" align='center'>
                    </el-table-column>
                    <el-table-column width="120" property="isvalid" :formatter="formatter_isvalid" label="是否有效"
                                     align='center'>
                    </el-table-column>
                    <el-table-column width="120" property="xillcode01" label="疾病代码1" align='center'>
                    </el-table-column>
                    <el-table-column width="120" property="xillname01" label="疾病名称1" align='center'>
                    </el-table-column>

                    <el-table-column width="120" property="xillcode02" label="疾病代码2" align='center'>
                    </el-table-column>
                    <el-table-column width="120" property="xillname02" label="疾病名称2" align='center'>
                    </el-table-column>

                    <el-table-column width="120" property="xillcode03" label="疾病代码3" align='center'>
                    </el-table-column>
                    <el-table-column width="120" property="xillname03" label="疾病名称3" align='center'>
                    </el-table-column>

                    <el-table-column width="120" property="xillcode04" label="疾病代码4" align='center'>
                    </el-table-column>
                    <el-table-column width="120" property="xillname04" label="疾病名称4" align='center'>
                    </el-table-column>

                    <el-table-column width="120" property="xillcode05" label="疾病代码5" align='center'>
                    </el-table-column>
                    <el-table-column width="120" property="xillname05" label="疾病名称5" align='center'>
                    </el-table-column>

                    <el-table-column width="120" property="xillcode06" label="疾病代码6" align='center'>
                    </el-table-column>
                    <el-table-column width="120" property="xillname06" label="疾病名称6" align='center'>
                    </el-table-column>

                    <el-table-column width="120" property="xillcode07" label="疾病代码7" align='center'>
                    </el-table-column>
                    <el-table-column width="120" property="xillname07" label="疾病名称7" align='center'>
                    </el-table-column>

                    <el-table-column width="120" property="xillcode08" label="疾病代码8" align='center'>
                    </el-table-column>
                    <el-table-column width="120" property="xillname08" label="疾病名称8" align='center'>
                    </el-table-column>
                    <el-table-column fixed="right" label="操作" align='center'>
                        <template slot-scope="scope">
                            <span class="operationIcon mr5" @click="detailNote(scope.row)">
                                <el-tooltip class="item" effect="light" content="详情" placement="top">
                                    <i class="el-icon-document"></i>
                                </el-tooltip>
                            </span>
                            <span class="operationIcon ml5" v-if="!isHebao" @click="editNote(scope.row)" title="编辑">
                                 <el-tooltip class="item" effect="light" content="编辑" placement="top">
                                    <i class="el-icon-edit-outline"></i>
                                 </el-tooltip>
                            </span>
                            <span class="operationIcon ml5" v-else-if="!isEdit" @click="editNote(scope.row)" title="编辑">
                                 <el-tooltip class="item" effect="light" content="编辑" placement="top">
                                    <i class="el-icon-edit-outline"></i>
                                 </el-tooltip>
                            </span>
                        </template>
                    </el-table-column>
                </el-table>
                <el-row>
                    <el-col :span="24">
                        <div class="pagination">
                            <el-pagination background v-if='paginations.total > 0' :page-sizes="paginations.pageSizes"
                                           :page-size="paginations.pageSize"
                                           :layout="paginations.layout" :total="paginations.total"
                                           :current-page='paginations.pageIndex'
                                           @current-change='handleCurrentChange' @size-change='handleSizeChange'>
                            </el-pagination>
                        </div>
                    </el-col>
                </el-row>
            </div>
        </div>
        <!-- 弹框 -->
        <el-dialog title="NOTEPAD" :visible.sync="NotePadDialogVisible" width="800px" center>
            <el-row>
                <el-col :span="24">
                    <el-form label-width="100px">
                        <el-col :span="12">
                            <el-form-item label="客户号" prop="clntnum">
                                <el-input :disabled="status=='view'||status=='update' || isHbcl" clearable v-model.trim="note.clntnum"
                                          @blur="queryCustomer"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="客户名称" prop="clntname">
                                <el-input disabled clearable v-model.trim="note.clntname"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="客户类型" prop="clttype">
                                <el-select :disabled="status=='view'" placeholder="请选择" v-model.trim="note.clttype"
                                           @change="changeClttype">
                                    <el-option key="1" label="投保人" value="1">
                                    </el-option>
                                    <el-option key="2" label="被保人" value="2">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="是否有效" prop="isvalid">
                                <el-select :disabled="status=='view'" v-model.trim="note.isvalid">
                                    <el-option key="Y" label="是" value="Y">
                                    </el-option>
                                    <el-option key="N" label="否" value="N">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-button v-if="status!='view'" type="danger" @click="addXill" class="addXill">新增
                            </el-button>
                            <el-table
                                    :data="xillData"
                                    style="width: 100%">
                                <el-table-column
                                        prop="xillcode"
                                        label="疾病代码1"
                                        min-width="250">
                                    <template slot-scope="scope">
                                        <el-input placeholder="" v-model="scope.row.xillcode" disabled>
                                            <el-button @click="goChoose(scope.row,scope.$index)" v-if="status!='view'"
                                                       slot="append" icon="el-icon-more"></el-button>
                                        </el-input>
                                    </template>
                                </el-table-column>

                                <el-table-column
                                        prop="xillname"
                                        label="疾病名称1"
                                        show-overflow-tooltip
                                        min-width="400">
                                </el-table-column>
                                <el-table-column
                                        v-if="status!='view'"
                                        prop="address"
                                        label="操作">
                                    <template slot-scope="scope">
                                    <span class="operationIcon mr5" @click="deleteXill(scope.$index)">
                                         <el-tooltip class="item" effect="light" content="删除" placement="top">
                                            <i class="el-icon-delete"></i>
                                        </el-tooltip>
                                    </span>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </el-col>
                    </el-form>
                </el-col>
            </el-row>
            <span slot="footer" class="dialog-footer">
                 <el-button v-if="status!='view' && !allInfoReadOnly" type="primary" @click="saveEdit">保 存</el-button>
                 <el-button @click="NotePadDialogVisible = false">返回</el-button>
            </span>
        </el-dialog>

        <el-dialog title="备注信息" :visible.sync="opinionDialogVisible" width="60%" center>
            <div class="select-main">
                <el-table :data="notepadCodes" class="mt10" @row-click="getDesc">
                    <el-table-column property="descitem" label="备注代码"></el-table-column>
                    <el-table-column property="longdesc" label="备注说明"></el-table-column>
                </el-table>
                <!-- <div class="back-con">
                    <el-button type="danger" @click="opinionDialogVisible = false">返回</el-button>
                </div> -->
            </div>
            <span slot="footer" class="dialog-footer">
                 <el-button class="dangerbutton" @click="opinionDialogVisible = false">返回</el-button>
            </span>
        </el-dialog>
        <el-dialog title="国际伤病代码索引" :visible.sync="chooseIllVisible" width="60%" center append-to-body top="2vh">
            <selectXillComponent
                    @confirmXill="confirmXill"
            ></selectXillComponent>
        </el-dialog>

        <!-- 弹框 -->
        <el-dialog title="NOTEPAD历史记录" :visible.sync="NotePadHistoryDialogVisible" width="800px" center>
            <el-row>
                <el-table
                        :data="notepadList"
                        style="width: 100%">
                    <el-table-column
                            prop="notepfx"
                            label="客户类型"
                            min-width="100">
                        <template slot-scope="scope">
                            {{scope.row.notepfx | notepfxPige}}
                        </template>
                    </el-table-column>
                    <el-table-column
                            prop="notenum"
                            label="客户号"
                            show-overflow-tooltip
                            min-width="100">
                    </el-table-column>
                    <el-table-column
                            prop="effdate"
                            label="生效日期"
                            show-overflow-tooltip
                            min-width="100">
                    </el-table-column>
                    <el-table-column
                            prop="remdte"
                            label="提醒日"
                            show-overflow-tooltip
                            min-width="100">
                    </el-table-column>
                    <el-table-column
                            prop="remto"
                            label="提醒人"
                            show-overflow-tooltip
                            min-width="100">
                    </el-table-column>
                    <el-table-column
                            prop="remfreq"
                            label="提醒周期"
                            show-overflow-tooltip
                            min-width="100">
                    </el-table-column>
                    <el-table-column
                            prop="subkeyd"
                            label="备注代码"
                            show-overflow-tooltip
                            min-width="100">
                    </el-table-column>
                    <el-table-column
                            prop="noteline01"
                            label="备注1"
                            show-overflow-tooltip
                            min-width="200">
                    </el-table-column>
                    <el-table-column
                            prop="noteline02"
                            label="备注2"
                            show-overflow-tooltip
                            min-width="200">
                    </el-table-column>
                    <el-table-column
                            prop="noteline03"
                            label="备注3"
                            show-overflow-tooltip
                            min-width="200">
                    </el-table-column>
                    <el-table-column
                            prop="noteline04"
                            label="备注4"
                            show-overflow-tooltip
                            min-width="200">
                    </el-table-column>
                    <el-table-column
                            prop="noteline05"
                            label="备注5"
                            show-overflow-tooltip
                            min-width="200">
                    </el-table-column>

                </el-table>
            </el-row>
            <span slot="footer" class="dialog-footer">
                 <el-button @click="NotePadHistoryDialogVisible = false">返回</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
  import {mapState, mapGetters} from 'vuex'
  import constant from '@/utils/constant';
  import uwconstant from '@/utils/uwConstants';
  import appName from "@/api/appName";
  import selectXillComponent from "@/page/customerManage/selectXillComponent.vue";
  import {
    getListNotepadIcd,
    saveNotepadInfoIcd,
    initNotepad,
    queryIll,
    queryIllDisability,
    queryIllBySearch,
    getCustomerInfoDetail,
    getNotePadIcdList
  } from "@/api/customermanage/customerManage.js";
  import {listNotepad,checkWDfor400} from "@/api/underwriting/uw";

  export default {
    data() {
      return {
        NotePadHistoryDialogVisible: false,
        notepadList: [],
        insInfo: {},
        appInfo: {},
        isHbcl: false,
        isHebao: false,
        isEdit: false,
        opinionDialogVisible: false,
        notepfxs: uwconstant.notepfx,
        catables: uwconstant.catables,
        validTypes: uwconstant.validTypes,
        remfreqs: uwconstant.remfreqs,
        isbusiType: uwconstant.isbusiType,
        NotePadDialogVisible: false,
        loading: false,
        tableData: [],
        searchParams: {
          customerNo: '', //客户号
        },
        note: {
          clntnum: '',
          clntname: '',
          clttype: '',
          isvalid: '',
          xillname01: '',
          xillcode01: '',
          xillname02: '',
          xillcode02: '',
          xillname03: '',
          xillcode03: '',
          xillname04: '',
          xillcode04: '',
          xillname05: '',
          xillcode05: '',
          xillname06: '',
          xillcode06: '',
          xillname07: '',
          xillcode07: '',
          xillname08: '',
          xillcode08: ''
        },
        notepadCodes: [],
        agntnum01: null,
        pol: null,
        usercomp: null,
        userId: null,
        headClntnumList: [],
        noteList: [],
        curIndex: null,
        //需要给分页组件传的信息
        paginations: {
          total: 0,        // 总数
          pageIndex: 1,  // 当前位于哪页
          pageSize: 10,   // 1页显示多少条
          pageSizes: [5, 10, 15, 20],  //每页显示多少条
          layout: "total, sizes, prev, pager, next, jumper"   // 翻页属性
        },
        pickerOptions1: {
          disabledDate(time) {
            return time.getTime() < Date.now();
          }
        },
        clttypeOptions: [
          {label: '投保人', value: '1'}, {label: '被保人', value: '2'}
        ],
        xillData: [],
        xillDataIndex: '',
        chooseIllVisible: false,
        status: ""
      }

    },
    props: {
      allInfoReadOnly: {
        type: Boolean,
        default: false
      },
      clntnum: {
        type: String,
        default: ""
      },
      soucrce: {
        type: String,
        default: ""
      },
      reqtype: {
        type: String,
        default: ""
      },
      name: {
        type: String,
        default: ""
      },
      curUserId: {
        type: String,
        default: ""
      },
      insTabInfo: {
        type: String,
        default: ""
      },
      appTabInfo: {
        type: String,
        default: ""
      },
      applnum: {
        type: String,
        default: ""
      },
    },
    components: {
      selectXillComponent
    },

    created() {

      debugger
      if (this.soucrce) {

        if (this.soucrce == 'hebao') {
          this.isHebao = true;
          this.isHbcl = true;
          if (this.allInfoReadOnly) {
            this.isEdit = true;
          }
          this.insInfo = JSON.parse(this.insTabInfo);
          this.appInfo = JSON.parse(this.appTabInfo);

          if (this.reqtype == 'ins') {
            this.searchParams.customerNo = this.insInfo.clntnum;
          } else {
            this.searchParams.customerNo = this.appInfo.clntnum;
          }
          this.getList();
        } else if (this.soucrce == 'xuhe') {
          this.isHebao = true;
          if (this.allInfoReadOnly) {
            this.isEdit = true;
          }
          if (this.clntnum) {
            this.searchParams.customerNo = this.clntnum;
          }
          this.getList();
        }

      }


//          this.initdate();

    },
    mounted() {
    },
    methods: {
      handleSubmit() {
        this.getList();
      },
      queryCustomer() {
        if (!this.note.clntnum) {
          return;
        }
        this.note.clntname='';
        if (this.note.clntnum.length>8) {
            this.$message({
              message: '客户号只能输入8位数字！',
              type: 'error'
            });
          return;
        }
        let params = {
          customerNo: this.note.clntnum
        }
        
        this.$store.dispatch('loading/CHANGE_LOADING', true)
        getCustomerInfoDetail(params).then(res => {
          if (res.resultCode == constant.SUCCESS && res.data != null) {
            this.$store.dispatch('loading/CHANGE_LOADING', false)
            this.note.clntname = res.data.customerName;
          }
        }).catch(err => {
          console.log(err)
          this.$store.dispatch('loading/CHANGE_LOADING', false)
        })
      },
      changeClttype() {
        if (this.soucrce == 'hebao') {
          if (this.note.clttype == '1') {
            this.note.clntname = this.appInfo.oldName;
            this.note.clntnum = this.appInfo.clntnum;
          } else {
            this.note.clntname = this.insInfo.oldName;
            this.note.clntnum = this.insInfo.clntnum;
          }
        }
      },
      confirmXill(data) {
        this.xillData[this.xillDataIndex].xillname = data.xillname;
        this.xillData[this.xillDataIndex].xillcode = data.xillcode;
        this.xillData = JSON.parse(JSON.stringify(this.xillData))
        this.chooseIllVisible = false;
      },
      deleteXill(index) {
        this.xillData.splice(index, 1)
        console.log(this.xillData)
      },
      goChoose(row, index) {
        this.xillDataIndex = index;
        this.chooseIllVisible = true;
      },
      addXill() {
        if (this.xillData.length == 8) {
          this.$message({
            message: '最多设置8个疾病',
            type: 'error'
          });
          return;
        }
        this.xillData.push({
          xillcode: '',
          xillname: ''
        })
      },
      showNotepad() {
        this.opinionDialogVisible = true;
      },
      initdate() {
        this.$store.dispatch('loading/CHANGE_LOADING', true)
        initNotepad().then(res => {
          if (res.resultCode == constant.SUCCESS && res.data != null) {
            this.$store.dispatch('loading/CHANGE_LOADING', false)
            this.notepadCodes = res.data.notepadCode;
          }
        }).catch(err => {
          console.log(err)
          this.$store.dispatch('loading/CHANGE_LOADING', false)
        })
      },
      showHistory() {
        let params = {
          "clntnum": this.searchParams.customerNo,
          "life": this.searchParams.customerNo
        }
        this.$store.dispatch('loading/CHANGE_LOADING', true)
        listNotepad(params).then(res => {
          this.$store.dispatch('loading/CHANGE_LOADING', false)
          if (res.resultCode == constant.SUCCESS && res.data != null) {
            this.notepadList = res.data.notepadList
          }
          this.NotePadHistoryDialogVisible = true;
        }).catch(err => {

        })

      },
      addNotepade() {
      	this.status='add';
        if (this.soucrce == 'hebao' || this.soucrce == 'xuhe') {
          let clttype = "";
          if (this.reqtype == 'ins') {
            clttype = "1";
          } else {
            clttype = "2";
          }

          let params = {
            "clntnum": this.searchParams.customerNo,
            "clttype": "",
            "isvalid": ""
          }
          getNotePadIcdList(params).then(res => {
            if (res.resultCode == constant.SUCCESS && res.data) {
              if (res.data.length > 0) {
                this.$message({
                  message: '该客户号已存在notepad信息！',
                  type: 'error'
                });
                return false;
              }
            }

            this.status = "add"
            this.note = {
              clntnum: '',
              clntname: '',
              clttype: '',
              isvalid: '',
              xillname01: '',
              xillcode01: '',
              xillname02: '',
              xillcode02: '',
              xillname03: '',
              xillcode03: '',
              xillname04: '',
              xillcode04: '',
              xillname05: '',
              xillcode05: '',
              xillname06: '',
              xillcode06: '',
              xillname07: '',
              xillcode07: '',
              xillname08: '',
              xillcode08: ''
            };
            if (this.soucrce == 'hebao') {
              if (this.reqtype == 'ins') {
                this.note.clttype = '2';
                this.note.clntname = this.insInfo.oldName;
                this.note.clntnum = this.insInfo.clntnum;
              } else if (this.reqtype == 'app') {
                this.note.clttype = '1';
                this.note.clntname = this.appInfo.oldName;
                this.note.clntnum = this.appInfo.clntnum;
              }
            } else if (this.soucrce == 'xuhe') {
              this.note.clntname = this.name;
              this.note.clntnum = this.clntnum;
            }


            this.xillData = [];
            this.NotePadDialogVisible = true;
          }).catch(err => {
            console.log(err)
          })
        } else {
          this.status = "add"
          this.xillData = [];
          this.note = {
            clntnum: '',
            clntname: '',
            clttype: '',
            isvalid: '',
            xillname01: '',
            xillcode01: '',
            xillname02: '',
            xillcode02: '',
            xillname03: '',
            xillcode03: '',
            xillname04: '',
            xillcode04: '',
            xillname05: '',
            xillcode05: '',
            xillname06: '',
            xillcode06: '',
            xillname07: '',
            xillcode07: '',
            xillname08: '',
            xillcode08: ''
          };
          this.NotePadDialogVisible = true;
        }


      },
      // 查询列表
      getList() {
        if (this.searchParams.customerNo.length != '8') {
          this.$message({
            message: '客户号必须输入8位数字！',
            type: 'error'
          });
          return;
        }
        let params = {
          "clntnum": this.searchParams.customerNo,
          "pageSize": this.paginations.pageSize,
          "pageNumber": this.paginations.pageIndex,
          "pageSource": "CM" //客户管理-Notepad 
        };
        if (this.searchParams.customerNo) {
          let reg = /^[0-9]*$/
          let repl = new RegExp(reg);
          if (!repl.test(this.searchParams.customerNo)) {
            this.$message({
              message: '客户号必须为纯数字！',
              type: 'error'
            });
            return;
          }
          if (this.searchParams.customerNo.length != '8') {
            this.$message({
              message: '客户号只能输入8位数字！',
              type: 'error'
            });
            return;
          }
        }
        this.$store.dispatch('loading/CHANGE_LOADING', true)
        getListNotepadIcd(params).then(res => {
          this.$store.dispatch('loading/CHANGE_LOADING', false)
          if (res.resultCode == constant.SUCCESS && res.data.list.length) {
            this.paginations.total = res.data.total;
            this.tableData = res.data.list;
            if (this.soucrce == 'hebao' || this.soucrce == 'xuhe') {
              this.$emit('NoteSize', res.data.total);
            }
          } else {
            if (this.soucrce != 'hebao' && this.soucrce == 'xuhe') {
              this.$message({
                message: '无符合条件资料！',
                type: 'error'
              });
            }

            this.tableData = [];
            this.paginations.total = 0;
          }
        }).catch(err => {
          console.log(err)
        })
      },
      getDesc(row) {
        this.note['subkeyd'] = row.descitem;
        this.note['noteline01'] = row.longdesc;
        this.opinionDialogVisible = false;
      },
      // 每页多少条切换
      handleSizeChange(pageSize) {
        this.paginations.pageSize = pageSize;
        this.getList();
      },
      // 上下分页
      handleCurrentChange(page) {
        this.paginations.pageIndex = page;
        this.getList();
      },
      // 根据条件查询列表
      subGetList() {
        this.paginations.pageIndex = 1;
        this.getList();
      },
      // 清除查询条件
      resetSearch() {
        this.searchParams.customerNo = '';
      },
      ifnotepfx(val) {
        if (val.clttype == '1') {
          return '投保人'
        }
        if (val.clttype == '2') {
          return '被保人'
        }
      },
      formatter_isvalid(val) {
        if (val.isvalid == 'Y') {
          return '是'
        }
        if (val.isvalid == 'N') {
          return '否'
        }
      },
      ifflag01(val) {
        if (val.flag01 == '1') {
          return '寿险'
        }
        if (val.flag01 == '2') {
          return '重疾险'
        }
        if (val.flag01 == '3') {
          return '防癌险'
        }
        if (val.flag01 == '4') {
          return '意外险'
        }
        if (val.flag01 == '5') {
          return '医疗险'
        }
        if (val.flag01 == '6') {
          return '意外医疗险'
        }
        if (val.flag01 == '7') {
          return '百万医疗险'
        }
      },
      ifflag02(val) {
        if (val.flag02 == '0') {
          return '有效'
        }
        if (val.flag02 == '1') {
          return '无效'
        }
      },
      editNote(data) {
        this.status = "update";
        this.note = JSON.parse(JSON.stringify(data));
        console.log(this.note)
        this.xillData = [];
        if (this.note.xillname01) {
          this.xillData[0] = {};
          this.xillData[0].xillname = this.note.xillname01;
          this.xillData[0].xillcode = this.note.xillcode01;
        }
        if (this.note.xillname02) {
          this.xillData[1] = {};
          this.xillData[1].xillname = this.note.xillname02;
          this.xillData[1].xillcode = this.note.xillcode02;
        }
        if (this.note.xillname03) {
          this.xillData[2] = {};
          this.xillData[2].xillname = this.note.xillname03;
          this.xillData[2].xillcode = this.note.xillcode03;
        }
        if (this.note.xillname04) {
          this.xillData[3] = {};
          this.xillData[3].xillname = this.note.xillname04;
          this.xillData[3].xillcode = this.note.xillcode04;
        }
        if (this.note.xillname05) {
          this.xillData[4] = {};
          this.xillData[4].xillname = this.note.xillname05;
          this.xillData[4].xillcode = this.note.xillcode05;
        }
        if (this.note.xillname06) {
          this.xillData[5] = {};
          this.xillData[5].xillname = this.note.xillname06;
          this.xillData[5].xillcode = this.note.xillcode06;
        }
        if (this.note.xillname07) {
          this.xillData[6] = {};
          this.xillData[6].xillname = this.note.xillname07;
          this.xillData[6].xillcode = this.note.xillcode07;
        }
        if (this.note.xillname08) {
          this.xillData[7] = {};
          this.xillData[7].xillname = this.note.xillname08;
          this.xillData[7].xillcode = this.note.xillcode08;
        }
        console.log(this.xillData)
        this.NotePadDialogVisible = true;
      },
      //查看
      detailNote(data) {
        this.status = "view";
        this.note = JSON.parse(JSON.stringify(data));
        console.log(this.note)
        this.xillData = [];
        if (this.note.xillname01) {
          this.xillData[0] = {};
          this.xillData[0].xillname = this.note.xillname01;
          this.xillData[0].xillcode = this.note.xillcode01;
        }
        if (this.note.xillname02) {
          this.xillData[1] = {};
          this.xillData[1].xillname = this.note.xillname02;
          this.xillData[1].xillcode = this.note.xillcode02;
        }
        if (this.note.xillname03) {
          this.xillData[2] = {};
          this.xillData[2].xillname = this.note.xillname03;
          this.xillData[2].xillcode = this.note.xillcode03;
        }
        if (this.note.xillname04) {
          this.xillData[3] = {};
          this.xillData[3].xillname = this.note.xillname04;
          this.xillData[3].xillcode = this.note.xillcode04;
        }
        if (this.note.xillname05) {
          this.xillData[4] = {};
          this.xillData[4].xillname = this.note.xillname05;
          this.xillData[4].xillcode = this.note.xillcode05;
        }
        if (this.note.xillname06) {
          this.xillData[5] = {};
          this.xillData[5].xillname = this.note.xillname06;
          this.xillData[5].xillcode = this.note.xillcode06;
        }
        if (this.note.xillname07) {
          this.xillData[6] = {};
          this.xillData[6].xillname = this.note.xillname07;
          this.xillData[6].xillcode = this.note.xillcode07;
        }
        if (this.note.xillname08) {
          this.xillData[7] = {};
          this.xillData[7].xillname = this.note.xillname08;
          this.xillData[7].xillcode = this.note.xillcode08;
        }
        console.log(this.xillData)
        this.NotePadDialogVisible = true;
      },

      async check400(){
        let procflg = "";
        if (this.soucrce == 'hebao') {
          let params = {
            "applnum":this.applnum
          }
          await checkWDfor400(params).then(res => {
            if (res.resultCode == constant.SUCCESS) {
              procflg = res.data;
            }
          }).catch(err => {

          })
        }
        return procflg;
      },
      //保存
      async saveEdit() {
        if (this.note.clntnum.length!=8) {
            this.popMsg("客户号必须为8位数字", "error");
            return;
        }
        if (!this.note.clntname) {
            this.popMsg("客户名称不能为空", "error");
            return;
        }
      let procflg = await this.check400();
      if(procflg){
          if(procflg=="4" || procflg=="5" || procflg=="6"){
            this.popMsg("保单400状态为"+procflg+",请核实",'error');
            return false;
          }
        }
//
//              if (this.note.notepfx == null || this.note.notepfx.length == 0) {
//                  this.popMsg("注意:请输入客户类别", "error");
//                  return;
//              }
//
//              if (this.note.notenum == null || this.note.notenum.length == 0) {
//                  this.popMsg("注意:请输入客户代码", "error");
//                  return;
//              }
//              if (this.note.notenum) {
//                  let reg = /^[0-9]*$/
//                  let repl = new RegExp(reg);
//                  if (!repl.test(this.note.notenum)) {
//                      this.popMsg("注意:客户代码必须为纯数字!", "error");
//                      return;
//                  }
//                  if (this.note.notenum && this.note.notenum.length > 8) {
//                      this.popMsg("注意！客户代码长度超出8位了!", "error");
//                      return;
//                  }
//              }
//              if (this.note.effdate == null || this.note.effdate.length == 0) {
//                  this.popMsg("注意:请输入生效日期", "error");
//                  return;
//              }
//              if (this.note.remdte == null || this.note.remdte.length == 0) {
//                  this.popMsg("注意:请输入截止日期", "error");
//                  return;
//              }
//              if (this.note.effdate > this.note.remdte) {
//                  this.popMsg("注意:生效日期不能大于截止日期", "error");
//                  return;
//              }
//
//              if (this.note.subkeyd == null || this.note.subkeyd.length == 0) {
//                  this.popMsg("注意:请输入备注代码", "error");
//                  return;
//              }
//
//              if (this.note.subkeyd.length > 4) {
//                  this.popMsg("注意:备注代码长度不能大于4位数", "error");
//                  return;
//              }
//
//              let ll_userId = null;
//              let params1 = {
//                  "userId": this.userId
//              }
//
//              this.volidNote();

        console.log(this.xillData)
        if (this.xillData[0]) {
          this.note.xillname01 = this.xillData[0].xillname;
          this.note.xillcode01 = this.xillData[0].xillcode;
        } else {
          this.note.xillname01 = "";
          this.note.xillcode01 = "";
        }
        if (this.xillData[1]) {
          this.note.xillname02 = this.xillData[1].xillname;
          this.note.xillcode02 = this.xillData[1].xillcode;
        } else {
          this.note.xillname02 = "";
          this.note.xillcode02 = "";
        }
        if (this.xillData[2]) {
          this.note.xillname03 = this.xillData[2].xillname;
          this.note.xillcode03 = this.xillData[2].xillcode;
        } else {
          this.note.xillname03 = "";
          this.note.xillcode03 = "";
        }
        if (this.xillData[3]) {
          this.note.xillname04 = this.xillData[3].xillname;
          this.note.xillcode04 = this.xillData[3].xillcode;
        } else {
          this.note.xillname04 = "";
          this.note.xillcode04 = "";
        }
        if (this.xillData[4]) {
          this.note.xillname05 = this.xillData[4].xillname;
          this.note.xillcode05 = this.xillData[4].xillcode;
        } else {
          this.note.xillname05 = "";
          this.note.xillcode05 = "";
        }
        if (this.xillData[5]) {
          this.note.xillname06 = this.xillData[5].xillname;
          this.note.xillcode06 = this.xillData[5].xillcode;
        } else {
          this.note.xillname06 = "";
          this.note.xillcode06 = "";
        }
        if (this.xillData[6]) {
          this.note.xillname07 = this.xillData[6].xillname;
          this.note.xillcode07 = this.xillData[6].xillcode;
        } else {
          this.note.xillname07 = "";
          this.note.xillcode07 = "";
        }
        if (this.xillData[7]) {
          this.note.xillname08 = this.xillData[7].xillname;
          this.note.xillcode08 = this.xillData[7].xillcode;
        } else {
          this.note.xillname08 = "";
          this.note.xillcode08 = "";
        }
        this.$store.dispatch('loading/CHANGE_LOADING', true)
        saveNotepadInfoIcd(this.note).then(res => {
          this.$store.dispatch('loading/CHANGE_LOADING', false)
          if (res.resultCode == constant.SUCCESS) {
            this.NotePadDialogVisible = false;
            this.searchParams.customerNo=this.note.clntnum;
            this.getList();
          }
        }).catch(err => {
          console.log(err)
        })
      },
      chgCltType(note) {
        if (note.notepfx == "CN") {//客户
          // note.notenum = this.headClntnumList[0].clntnum;
        } else if (note.notepfx == "CH") {//保单
          note.notenum = this.pol;
        } else if (note.notepfx == "AG") {//代理
          note.notenum = this.agntnum01;
        }
      },
      popMsg(message, type) {
        this.$message({
          message: message,
          type: type
        });
      },
      volidNote() {
        let li_seq = 0;
        let params = {
          "notepfx": this.note.notepfx,
          "notecoy": this.note.notecoy,
          "notenum": this.note.notenum,
          "subkeyd": this.note.subkeyd
        }

        let ls_notetype = "";
        let ls_screen = "";
        if (this.note.notepfx == "CN") {
          ls_notetype = 'CLNT';
          ls_screen = 'S2465';
        } else if (this.note.notepfx == "CH") {
          ls_notetype = 'CHDR';
          ls_screen = 'S6353';
        } else {
          ls_notetype = 'AGNT';
          ls_screen = 'S9159';
        }

        // this.note.notecoy = this.usercomp;
        // this.note.notecoy = "2";
        // note.noteseq = ls_seq;
        this.note.notetype = ls_notetype;
        this.note.termid = "GZTW";
        // note.user = ll_userId;
        this.note.screen = ls_screen;
        this.note.rembrn = "10";
        this.note.jobName = "EUIS";
        // note.datime = this.initTime();
        // this.note.userProfile = this.userId;
      },
    },
    computed: {
      ...mapGetters(['tags']),
      reload() {
        return this.$store.state.loading.reload;
      }
    },
    activated() {
      if (this.reload) {
        this.$store.dispatch('loading/CHNAGE_RELOAD', false)
        Object.assign(this.$data, this.$options.data());
      }
      document.onkeydown = (event) => {
        var e = event || window.event || arguments.callee.caller.arguments[0];
        if (e && e.keyCode == 113) {
          this.getList();
        }
      };
    },
    filters: {
      remtoPige: function (value) {
        if(value==''){
          return ''
        }else{
          return '';
        }
      },
      notepfxPige: function (value) {
        if(value=='CN'){
          return '客户'
        }else if(value=='CH'){
          return '保单'
        }else if(value=='AG'){
          return '代理'
        }else{
          return '';
        }
      },
    }
  }

</script>

<style lang="less" scoped>
    .fillcontain {
        padding-bottom: 0;
    }

    .contain {
        background: #fff;
        padding: 10px;
        margin-bottom: 20px;
    }

    .pagination {
        padding: 10px 20px;
        text-align: right;
    }

    .operationIcon {
        border: 1px solid #e5e5e5;
        border-radius: 50%;
        width: 22px;
        height: 22px;
        display: inline-block;
        cursor: pointer;
        box-shadow: 0 0 3px #f9f9f9;

        .item i {
            color: #68a3fc;
        }
    }

    .search_container {
        padding: 20px 20px 0 20px;
    }

    .addXill {
        margin-bottom: 10px;
    }
</style>